package cn.tedu.review;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

/*本类用于定义单元测试方法*/
public class TestStudent {
    @Test  //相当于调用本类入口函数调用main方法
    public void getStu() {
        //1.创建学生对象
        Student s1 = new Student("张三", 3, '男');
        Student s2 = new Student("李四", 4, '女');
        Student s3 = new Student("王五", 5, '男');
        Student s4 = new Student("赵六", 6, '女');
        //2.向数组中存入学生对象
        /*Student[] a = new Student[4];
        a[0] = s1;
        a[1] = s2;
        a[2] = s3;
        a[3] = s4;*/

//        Student[] a = new Student[]{s1,s2,s3,s4};
        Student[] a = {s1,s2,s3,s4};
        System.out.println(Arrays.toString(a));//直接打印
        for(int i = 0;i< a.length ; i++){
            Student s = a[i]; //赋值给类的对象:Student类的变量名s(栈的区域新建Studnet类),可以保存Student类的对象
            System.out.println(s.getName());
            System.out.println(s.getAge()); //自定义对象封装属性,写了getSet方法,类似文档数组下文档对象File[0]调用getName()方法
            System.out.println(s.getGender());
//            System.out.println(a[i].getName());
//            System.out.println(a[i].getAge());
//            System.out.println(a[i].getGender());
        }
    }
}
